package com.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ObjectUtils {
	
	public static Object getNotNull(Object obj){
		return obj==null?"":obj;
	}
	
	public static String getStrVal(Object obj){
		return obj==null?"":String.valueOf(obj);
	}
	
	public static int getIntVal(String s){
		int val = 0;
		try {
			val = Integer.parseInt(s);
			return val;
		} catch (Exception e) {
			return val;
		}
	}
	
	public static float getFloatVal(String s){
		float val = 0;
		try {
			val = Float.parseFloat(s); 
			return val;
		} catch (Exception e) {
			return val;
		}
	}
	
	public static Date getDateVal(String s) throws ParseException{
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
		
		return df.parse(s);
				
	}
	
	
}
